home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 3 / BBS in a box - Trilogy III.iso / Files / Prog / A / AE Sample (TC5) / Printing.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-01-07  |  1.9 KB  |  86 lines  |  [TEXT/KAHL]

  1. /* Printing.c */
  2.  
  3. #include "AESimple.h"
  4.  
  5. void PrintWindow(WindowPtr wp)
  6. {
  7.     wiHand    info = (wiHand)GetWRefCon(wp);
  8.     THPrint    printInfo;
  9.     short    pageNum = 1;
  10.     short    vPages, hPages;
  11.     short    vCount, hCount;
  12.     short    pageWidth, pageHeight;
  13.     Rect    pageRect;
  14.     Rect    pictRect;
  15.     TPPrPort printPortPtr;
  16.     TPrStatus printStatus;
  17.     
  18.     PrOpen();
  19.     printInfo     = (*info)->printInfo;
  20.     PrValidate(printInfo);
  21.     pageRect     = (*printInfo)->prInfo.rPage;
  22.     pictRect     = (*info)->picBounds;
  23.     pageWidth     = (pageRect.right - pageRect.left);
  24.     pageHeight     = (pageRect.bottom - pageRect.top);
  25.     
  26.     /* Calculate how tall and wide the resulting image will be */
  27.     vPages = (pictRect.bottom - pictRect.top) / pageHeight + 1;
  28.     hPages = (pictRect.right - pictRect.left) /  pageWidth + 1;
  29.     
  30.     printPortPtr = PrOpenDoc(printInfo,
  31.      NIL,
  32.       NIL);
  33.  
  34.     /* print each page */
  35.     for (hCount = 0; hCount < hPages; hCount++)
  36.         for (vCount = 0; vCount < vPages; vCount++) {
  37.             PrOpenPage(printPortPtr, NIL);
  38.             SetPort((GrafPtr)printPortPtr);
  39.             pictRect = (*info)->picBounds;
  40.             OffsetRect(&pictRect, -pageWidth * hCount, -pageHeight * vCount);
  41.             DrawPicture((*info)->thePicture, &pictRect);
  42.             PrClosePage(printPortPtr);
  43.     }
  44.  
  45.     PrCloseDoc(printPortPtr);
  46.     
  47.     if ((PrError() == noErr) && ((*printInfo)->prJob.bJDocLoop == bSpoolLoop)) 
  48.         PrPicFile(printInfo, NIL, NIL, NIL, &printStatus);
  49.     
  50.     SetPort(wp);
  51.  
  52.     PrClose();
  53. }
  54.  
  55. Boolean ShowJobDialog(WindowPtr wp)
  56. {
  57.     wiHand    info = (wiHand)GetWRefCon(wp);
  58.     Boolean    result = TRUE;
  59.     OSErr    err = noErr;
  60.     
  61.     err = MyInteractWithUser(FALSE);
  62.     if (err == noErr) {
  63.         PrOpen();
  64.         result = PrJobDialog((**info).printInfo);
  65.         PrClose();
  66.     }
  67.     return result;
  68. } /* ShowJobDialog */
  69.  
  70.  
  71. Boolean ShowSetupDialog(WindowPtr wp)
  72. {
  73.     wiHand    info = (wiHand)GetWRefCon(wp);
  74.     Boolean    result = TRUE;
  75.     OSErr    err = noErr;
  76.     
  77.     err = MyInteractWithUser(FALSE);
  78.     if (err == noErr) {
  79.         PrOpen();
  80.         result = PrStlDialog((**info).printInfo);
  81.         PrClose();
  82.     }
  83.     
  84.     return result;
  85. } /* ShowSetupDialog */
  86.